home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
multi_re
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
5KB
From @VM.CC.PURDUE.EDU:SCHUTZ@Rollins.Bitnet Tue Jan 29 19:10:57 1991
Received: from zoo.ecn.purdue.edu by en.ecn.purdue.edu (5.65/1.30jrs)
id AA17776; Tue, 29 Jan 91 19:10:57 -0500
From: @VM.CC.PURDUE.EDU:SCHUTZ@Rollins.Bitnet
Received: from vm.cc.purdue.edu by zoo.ecn.purdue.edu (5.65/1.30jrs)
id AA05157; Tue, 29 Jan 91 19:10:52 -0500
Received: from Rollins.Bitnet (SCHUTZ) by PURCCVM.BITNET (Mailer R2.07) with
BSMTP id 7264; Tue, 29 Jan 91 19:10:42 EST
Date: Tue, 29 Jan 91 16:22 EST
Subject: Schutz's REGR.TXT for HP48SX from Compuserve
To: wscott@ecn.purdue.edu
Message-Id: <C8F223CA17BF000371@Rollins.Bitnet>
X-Envelope-To: wscott@ecn.purdue.edu
X-Vms-To: IN%"wscott@ecn.purdue.edu"
Status: OR
%%HP: T(3)A(D)F(.);
@
@ REGR -- a multivariate statistical regression utility.
@
@ Eric Schutz, Rollins College, Winter Park, FL 32789
@ (bitnet: SCHUTZ at ROLLINS)
@ January, 1991
@
@ This program enables the HP48SX to estimate the "best fit" or linear
@ regression of a dependent variable on <several> independent variables --
@ extending the calculator's built-in bivariate regression capability to a
@ <multivariate> capability. Enter as input on the stack:
@
@ 2: 'name'
@ 1: {list}
@
@ where 'name' is the name of the data input matrix and {list} is a list of
@ the column-numbers in 'name' that are the regression variables, beginning
@ with the dependent-variable column. Thus << FRED { 2 1 4 6 } REGR >> would
@ regress column-2 (the dependent-variable) on columns-1, -4 and -6 (the
@ independent-variables, respectively) in the input matrix FRED.
@
@ NOTE: (i) REGR uses the statistics data matrix \GSDAT: be sure you do NOT
@ have any data stored in that matrix that you don't mind losing! (ii) Be sure
@ there ARE enough "degrees of freedom" for the calculations involved:
@ the number of observations in your data set must exceed the number of
@ variables in the regression, and there must be no "perfect multi-
@ collinearity" among the independent variables.
@
@ REGR leaves the input-data matrix itself unaffected, it uses no flags, and
@ it leaves unaffected any objects already on the stack. The output of the
@ REGR program consists of the following variables that are created in the
@ current directory:
@
@ B -- array of coefficient estimates, beginning with the intercept
@ term, then the slope terms in the same order as in the input
@ list.
@
@ \Gs.B -- array of standard errors of the corresponding coefficient
@ estimates in B.
@
@ T.B -- array of t-statistics of the corresponding coefficient
@ estimates in B.
@
@ P.B -- array of P-values of the corresponding coefficient estimates
@ in B.
@
@ R2 -- "R-squared" of the regression.
@
@ R2J -- adjusted "R-squared" of the regression.
@
@ \Gs2 -- square of the standard error of the regression.
@
@ DF -- degrees of freedom.
@
@ F -- F-statistic for the regression.
@
@ P.F -- P-value of the F-statistic for the regression.
@
@ TSS -- total sum of squares for ANOVA.
@
@ ESS -- explained sum of squares for ANOVA.
@
@ RSS -- residual sum of squares for ANOVA.
@
@ DW -- Durbin-Watson statistic.
@
@ VC.B -- variance-covariance matrix of the coefficient estimates in B.
@
@ RESID -- array of residuals from the regression-line.
@
@ PRED -- array of predicted-values of the dependent-variable.
@
@
\<< \-> MNAME CNUMS
\<< CL\GS MNAME RCL
SIZE 1 GET \-> N
\<< CNUMS 1 GET \->
DV
\<< 1 N
FOR I MNAME
RCL { I DV } GET
NEXT { N 1
} \->ARRY 'Y' STO 1 N
START 1
NEXT N
\->ARRY \GS+
\>> CNUMS SIZE
2 SWAP
FOR J CNUMS J
GET \-> CN
\<< 1 N
FOR I
MNAME RCL { I CN }
GET
NEXT N
\->ARRY \GS+
\>>
NEXT RCL\GS TRN
'X' STO CL\GS X TRN X
* INV X TRN Y * *
'B' STO X B *
'PRED' STO Y PRED -
'RESID' STO RESID
TRN RESID * N CNUMS
SIZE - / ARRY\-> DROP
'\Gs2' STO \Gs2 X TRN X
* INV * 'VC.B' STO
1 CNUMS SIZE
FOR J 'VC.B'
RCL { J J } GET \v/
NEXT CNUMS
SIZE \->ARRY '\Gs.B'
STO 1 CNUMS SIZE
FOR J 'B' RCL
J GET '\Gs.B' RCL J
GET /
NEXT CNUMS
SIZE \->ARRY 'T.B'
STO 1 CNUMS SIZE
FOR J 'T.B'
RCL J GET ABS N
CNUMS SIZE - SWAP
UTPT
NEXT CNUMS
SIZE \->ARRY 'P.B'
STO Y \GS+ MEAN \-> \GmY
\<< B TRN X TRN
* X * B * ARRY\->
DROP N \GmY SQ * - Y
TRN Y * ARRY\-> DROP
N \GmY SQ * - / 'R2'
STO 1 1 R2 - N 1 -
* N CNUMS SIZE - /
- 'R2J' STO CL\GS
RESID ARRY\-> 1 GET 1
- 1 2 \->LIST \->ARRY
SWAP DROP RESID
ARRY\-> SWAP DROP 1
GET 1 - 1 2 \->LIST
\->ARRY -1 * - STO\GS
TOT RESID TRN RESID
* ARRY\-> DROP DUP
'RSS' STO / 'DW'
STO CL\GS Y DUP STO\GS
TRN Y * ARRY\-> DROP
N MEAN SQ * - 'TSS'
STO TSS RSS - 'ESS'
STO N CNUMS SIZE -
'DF' STO ESS CNUMS
SIZE 1 - / RSS DF /
/ 'F' STO CNUMS
SIZE 1 - DF F UTPF
'P.F' STO { B \Gs.B
T.B P.B R2 R2J \Gs2
DF F P.F TSS ESS
RSS DW VC.B RESID
PRED } ORDER { X Y
} PURGE CL\GS
\>>
\>>
\>>
\>>